<?php

    // +----------------------------------------------------------------------
    // | 行为日志模型
    // +----------------------------------------------------------------------
    // | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
    // +----------------------------------------------------------------------
    // | Author: 微尘 <yicmf@qq.com>
    // +----------------------------------------------------------------------

    namespace app\model\ucenter;

    use think\facade\Db;
    use yicmf\tools\FlowSn;

    class UserCash extends Common
    {

        public static $money_type = [
                '1'=>'余额提现',
                '2'=>'提现驳回',
                '6'=>'充值余额',
                '11'=>'直推奖',
                '19'=>'间接奖',
                '12'=>'平级奖',
                '13'=>'级差奖',
                '14'=>'隔代奖',
                '17'=>'培养奖',
                '15'=>'一级邀请奖励',
                '16'=>'二级邀请奖励',
                '18'=>'推广一名合伙人',
                '20'=>'推广团队奖励',
                '21'=>'推广合伙人奖励',
                '30'=>'发布任务',
                '31'=>'缴纳竞拍保证金',
                '32'=>'支付推荐费用',
                '33'=> '竞拍成功',
                '34'=> '竞拍违约',
                '35'=> '任务变动',
                '36'=> '发布手机接单退回',
                '66'=> '服务商收益',
                '88'=> '财务管理',
//            -----以上旧版程序---
                '90'=> 'POS交易返佣',
                '91'=> '流量返现（专项）',
                '92'=> '交易返现（专项）',
                '93'=> '升级押金'
             ];

        // 定义关联方法
        public function user()
        {
            return $this->belongsTo(User::class);
        }

		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['ip'] = request()->ip();
			$data['sn'] = FlowSn::build('TX');
//			$data['os'] = request()->server('HTTP_USER_AGENT');
			$data['param'] = '';
		}


//        public function getCreateTimeAttr($value,$data)
//        {
//            return date('Y-m-d H:i:s',$value);
//        }
//
//        public function getAuditTimeAttr($value,$data)
//        {
//            return date('Y-m-d H:i:s',$value);
//        }

    }
